package com.ruoyi.api.customer;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.CrmDataStatus;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.CCustomerLabel;
import com.ruoyi.system.domain.CrmUserRecord;
import com.ruoyi.system.domain.dto.CCustomerLabelCount;
import com.ruoyi.system.service.ICCustomerLabelService;
import com.ruoyi.system.service.ICrmUserRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2020-10-14
 */
@RestController
@RequestMapping("/api/crmUserLabel")
public class CrmUserLabelController extends BaseController
{
    @Autowired
    private ICCustomerLabelService customerLabelService;

    /**
     * 根据客户id获取标签信息
     * @return
     */
    @GetMapping("/getListByCusId")
    public AjaxResult getListByCusId(Long customerId)
    {
        if(customerId == null){
            return AjaxResult.error("用户无效");
        }
        CCustomerLabel cCustomerLabel=new CCustomerLabel();
        cCustomerLabel.setCusId(customerId);
        List<CCustomerLabel> list = customerLabelService.selectCCustomerLabelList(cCustomerLabel);
        return AjaxResult.success(list);
    }

    /**
     * 获取用户标签情况及对应的客户数量
     * @return
     */
    @GetMapping("/getListCount")
    public AjaxResult getListCount()
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        Long userId=loginUser.getUser().getUserId();
        List<CCustomerLabelCount> list = customerLabelService.selectCrmLabelCount(userId);
        return AjaxResult.success(list);
    }



}
